home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Moscow ML 1.31 / source code / mosml / src / mosmllib / Real.sig < prev    next >
Encoding:
Text File  |  1996-07-03  |  3.3 KB  |  101 lines  |  [TEXT/R*ch]

  1. (* Real -- SML Standard Library *)
  2.  
  3. type real = real
  4.  
  5. exception Div
  6. and Overflow
  7.  
  8. val ~    : real -> real
  9. val +    : real * real -> real
  10. val -    : real * real -> real
  11. val *    : real * real -> real
  12. val /    : real * real -> real
  13. val abs  : real -> real
  14. val min  : real * real -> real
  15. val max  : real * real -> real
  16. val sign : real -> int
  17. val compare : real * real -> ordering
  18.  
  19. val sameSign    : real * real -> bool
  20. val toDefault   : real -> real
  21. val fromDefault : real -> real
  22.  
  23. val floor : real -> int
  24. val ceil  : real -> int
  25. val trunc : real -> int
  26. val round : real -> int
  27. val real  : int -> real
  28.  
  29. val >    : real * real -> bool
  30. val >=   : real * real -> bool
  31. val <    : real * real -> bool
  32. val <=   : real * real -> bool
  33.  
  34. val toString   : real -> string
  35. val fromString : string -> real option
  36. val scan       : {getc : 'a -> (char * 'a) option} -> 'a -> (real * 'a) option
  37. val fmt        : StringCvt.realfmt -> real -> string
  38.  
  39. (* [~, *, /, +, -, >, >=, <, <=, abs] are the usual operations
  40.    on reals, as prescribed by the Definition.
  41.  
  42.    [min(x, y)] is the smaller of x and y.
  43.  
  44.    [max(x, y)] is the larger of x and y.
  45.  
  46.    [sign x] is ~1, 0, or 1, according as x is negative, zero, or positive.
  47.  
  48.    [compare(x, y)] returns LESS, EQUAL, or GREATER, according 
  49.    as x is less than, equal to, or greater than y.
  50.  
  51.    [sameSign(x, y)] is true iff sign x = sign y.
  52.  
  53.    [toDefault x] is x.
  54.  
  55.    [fromDefault x] is x.
  56.  
  57.    [floor r] is the largest integer <= r (rounds towards minus infinity).
  58.  
  59.    [ceil r] is the smallest integer >= r (rounds towards plus infinity).
  60.  
  61.    [trunc r] is numerically largest integer between r and zero 
  62.    (rounds towards zero).
  63.  
  64.    [round r] is the integer nearest to r.  In case of a tie, rounds to 
  65.    nearest numerically larger integer.  NOTE: This isn't the required
  66.    behaviour: it should round to nearest even integer in case of a tie.
  67.  
  68.    [fmt spec r] returns a string representing r, in the format
  69.    specified by spec.
  70.  
  71.       spec          description                            C printf 
  72.       ---------------------------------------------------------------
  73.       SCI NONE      scientific,   6 digits after point       %e
  74.       SCI (SOME n)  scientific,   n digits after point       %.ne
  75.       FIX NONE      fixed-point,  6 digits after point       %f
  76.       FIX (SOME n)  fixed-point,  n digits after point       %.nf
  77.       GEN NONE      auto choice, 12 significant digits       %.12g
  78.       GEN (SOME n)  auto choice,  n significant digits       %.ng
  79.  
  80.    [toString r] returns a string representing r, with automatic choice
  81.    of format according to the magnitude of r.  
  82.    Equivalent to (fmt (GEN NONE) r).
  83.    
  84.    [fromString s] returns SOME(r) if a floating-point numeral can be
  85.    scanned from a prefix of string s, ignoring any initial whitespace;
  86.    returns NONE otherwise.  The valid forms of floating-point numerals
  87.    are described by:
  88.     [+~-]?(([0-9]+(\.[0-9]+)?)|(\.[0-9]+))([eE][+~-]?[0-9]+)?
  89.  
  90.    [scan {getc} charsrc] attempts to scan a floating-point number from
  91.    the character source charsrc, using the accessor getc, and ignoring
  92.    any initial whitespace.  If successful, it returns SOME(r, rest)
  93.    where r is the number scanned, and rest is the unused part of the
  94.    character source.  The valid forms of floating-point numerals
  95.    are described by:
  96.     [+~-]?(([0-9]+(\.[0-9]+)?)|(\.[0-9]+))([eE][+~-]?[0-9]+)?
  97. *)
  98.  
  99.  
  100.  
  101.